/*
 Xern Entity Relocation Network
 Copyright (C) 2011 Ronie Salgado <roniesalg@gmail.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
*/

#ifndef XERN_TEXTURE_HPP
#define XERN_TEXTURE_HPP

#include <OgreRoot.h>
#include "Xern/ITexture.hpp"

namespace XernOgre
{
	using namespace Xern;

	class Texture: public ITexture
	{
	public:
		Texture(Ogre::TexturePtr texture, TextureFormat format, size_t dataLen, const void *data);
		~Texture();

		virtual ResourceFlags GetFlags() const;
		virtual void UpdateState(boost::shared_ptr<IDataFilter> stateData);

		virtual const uuid &GetId() const;
		virtual void SetId(const uuid &id);

		virtual int GetMipMaps() const;
		virtual int GetWidth() const;
		virtual int GetHeight() const;
		virtual int GetDepth() const;

		virtual TextureFormat GetFormat() const;
		virtual bool UploadLevel(int level, size_t len, const void *data);
		virtual bool ReadLevel(int level, size_t len, void *buffer);

	private:
		friend class Material;
		uuid id;
		Ogre::TexturePtr texture;
		TextureFormat format;
		size_t pixelDataLen;
		char *pixelData;
	};

}; // namespace XernOgre

#endif //XERN_TEXTURE_HPP
